Advanced Actual Attribute Price v.1.4.1.
Author: Hadir Elba
by Kiril Nedelchev <kikoleppard@hotmail.bg>
August, 1 , 2005 - MODIFIED for Attribute Suite v.1.2.3
- For Attribute Suite v.1.2.3 I have removed a little bit code - the last points. There was a bug with calculation of the attribute prices when the product price is $0.
- added compatibility with Option Type Feature 1.7.1. - for all option types in catalog/product_info.php
view catalog/product_info.php
Use it freely. All I ask is you keep my name/domain in the comments. THANK YOU
This allows for the attribute price to replace the product price
'0' values allowed
for support
yamasr
-AT- hotmail.com
donations accepted (and needed) through paypal :) THANK YOU
Also you can post/check here
http://forums.oscommerce.com/index.php?showtopic=69543 if you need help.
Color codes
This is what it was or where to change
This is what it is changed to or
added
CATALOG/INCLUDES/CLASS/SHOPPING_CART.PHP
Step 1- Under
$this->weight += ($qty *
$products_weight);
}
REMOVE EVERYTHING THAT HAS TO DO WITH ATTRIBUTES
and add this
// phpmom.com advanced attribute price
if (isset($this->contents[$products_id]['attributes'])) {
reset($this->contents[$products_id]['attributes']);
while (list($option, $value) =
each($this->contents[$products_id]['attributes'])) {
$attribute_price_query = tep_db_query("select options_values_price, price_prefix
from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$prid . "'
and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value
. "'");
$attribute_price = tep_db_fetch_array($attribute_price_query);
if ($attribute_price['price_prefix'] == '+') {
$this->total += $qty * tep_add_tax($attribute_price['options_values_price'],
$products_tax);
} elseif ($attribute_price['price_prefix'] == '-') {
$this->total -= $qty * tep_add_tax($attribute_price['options_values_price'],
$products_tax);
}
elseif ($attribute_price['price_prefix'] == '')
{ //comment where you see //'0' if want '0' value
// if ($attribute_price['options_values_price'] == '0') { //'0'
// $this->total += 0; //'0'
// } //'0'
// if ($attribute_price['options_values_price'] != '0') { //'0'
$this->total += tep_add_tax($attribute_price['options_values_price'],
$products_tax) * $qty - (tep_add_tax($products_price, $products_tax) * $qty);
// }//'0'
}else $this->total += $qty *
tep_add_tax($attribute_price['options_values_price'], $products_tax);
}
}
there should be two } after that
//////////////////////////////////////////////////
Step 2. - For the function
attributes_price($products_id)
Delete the whole thing and add this
//PHPMOM.COM AAP
function attributes_price($products_id)
{
$attributes_price = 0;
if (isset($this->contents[$products_id]['attributes'])) {
reset($this->contents[$products_id]['attributes']);
while (list($option, $value) =
each($this->contents[$products_id]['attributes'])) {
$attribute_price_query = tep_db_query("select options_values_price, price_prefix
from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" .
(int)$products_id . "' and options_id = '" . (int)$option . "' and
options_values_id = '" . (int)$value . "'");
$attribute_price = tep_db_fetch_array($attribute_price_query);
if ($attribute_price['price_prefix'] == '+') {
$attributes_price += $attribute_price['options_values_price'];
} elseif ($attribute_price['price_prefix'] == '-') {
$attributes_price -= $attribute_price['options_values_price'];
}
else
$attributes_price+= $attribute_price['options_values_price'];
}
}
return $attributes_price;
}
Step 3. - above
$products_array[] = array('id' => $products_i
add
//BOF PHPMOM.COM AAP//hadir
$attributes_price = 0;
if (isset($this->contents[$products_id]['attributes'])) {
reset($this->contents[$products_id]['attributes']);
while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {
$attribute_price_query = tep_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$products_id . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'");
$attribute_price = tep_db_fetch_array($attribute_price_query);
if ($attribute_price['price_prefix'] == '') {
$attributes_price += ($attribute_price['options_values_price']-$products_price);
} elseif ($attribute_price['price_prefix'] == '+') {
$attributes_price += $attribute_price['options_values_price'];
}
elseif ($attribute_price['price_prefix'] == '-') {
$attributes_price -= $attribute_price['options_values_price'];
}
}
}
//eof actual attribute//hadir
////////////////////////////////////////////////////////////////////////
CATALOG/PRODUCT_INFO.PHP (Or product_info.tpl.php for template/loaded)
Step 4 . - To display '0' values change this in
Change
if
($products_options['options_values_price'] != '0') {
to
//BOF PHPMOM.COM AAP
if
(($products_options['options_values_price'] !=
'0')||(($products_options['options_values_price'] ==
'0')&&($products_options['price_prefix'] == ''))) { //eof aap
Go to Step b.1.7 - Hide price if $0 v.2.0